// 患者列表
<template>
  <div>
    <TopManu  :thatF='this' :signOut="true" @handleQuit="$router.go(-1)" @handcreate="handcreate"></TopManu>
     <el-row>
    <el-col :span="24" style="margin:20px 0;text-align:right;padding:0 20px;" class="demo-form-inline">
       <el-form :inline="true" :model="Inquire" label-width="auto"  style="text-align:left;">
          <el-form-item label="关键字123">
            <el-input v-model="Inquire.keyword" placeholder="关键字"></el-input>
          </el-form-item>
          <el-form-item label="创建时间">
            <el-date-picker
              v-model="Inquire.created_at"
              type="datetimerange"
              :picker-options="pickerOptions"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              align="right">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="状态">
            <el-radio-group v-model="Inquire.status">
              <el-radio label="">全部</el-radio>
              <el-radio :label="1">正常</el-radio>
              <el-radio :label="2">拉黑</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="()=>{tableData = [],getMemberIndex()}">查询</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="()=>{page = 1,Object.keys(Inquire).forEach(key=>{Inquire[key] = '',tabData = [],getMemberIndex()})}">重置</el-button>
          </el-form-item>
          <el-form-item  style="marginLeft:auto;">
             <el-button type="primary" @click="()=>{listFlag = true,listType = 2}">添加人员</el-button>
          </el-form-item>

         
       </el-form>
       
    </el-col>
    <el-col :span="24" class="fromFlex">
      <FromList @handleEdit="handleEdit" @handleSwitchChange="handleSwitchChange" :tableTitle="tableTitle" :tableData="tableData" />
     <!-- <el-col :span="20" style="marginTop:20px auto;"> -->
        <el-pagination
        background
        style="marginTop:20px;"
        :current-page="page"
        :page-size="limit"
        layout="total , prev, pager, next , jumper"
        @current-change="handlePagination"
        :total="userCount">
        </el-pagination>
      <!-- </el-col> -->
    </el-col>
    
    <el-dialog
      :title="listType == 1 ? '查看患者信息' : listType == 2 ? '添加患者信息' : '编辑患者信息'"
      :visible.sync="listFlag"
      width="100%"
      :top="top"
      :before-close="handleClose">
      <span>
        <el-col :span="24">
          <el-form :inline="false" :model="listUser" label-width="110px" style="text-align:left;">
            <el-col :span="24" style="font-size:24px;margin:0px 0 10px 0;">
                基本信息
            </el-col>
            <el-col :span="24">       
              <el-col :span="6"> 
                <el-form-item label="姓名:">
                  <el-input v-model="listUser.name" placeholder="请输入姓名" :disabled="listType == 1"></el-input>
                </el-form-item>
              </el-col>
                   <el-col :span="6">
                <el-form-item label="身份证号码:">
                   <el-input v-model="listUser.id_card" @blur="getInfo2(listUser.id_card)" :disabled="listType == 1" placeholder="请输入身份证号码"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="性别:">
                  <el-select style="width:100%"  :disabled="listType == 1" v-model="listUser.gender" placeholder="请选择性别">
                    <el-option
                      v-for="item in sex"
                      :key="item.value"
                      :label="item.label"  
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="年龄:">
                  <el-input v-model="listUser.age" :disabled="listType == 1" placeholder="请输入年龄"></el-input>
                </el-form-item>
              </el-col>

            </el-col>
            <el-col :span="24">
              <el-col :span="6">
                <el-form-item label="出生日期:">
                  <el-date-picker
                      style="width:100%;"
                      v-model="listUser.birthday"
                      type="date"
                      :disabled="listType == 1"
                      placeholder="选择生日">
                    </el-date-picker>
                </el-form-item>
              </el-col>
                         
              <el-col :span="6">
                <el-form-item label="血型:">
                  <el-select style="width:100%" v-model="listUser.blood_type" :disabled="listType == 1" placeholder="请选择婚姻状况">
                    <el-option
                      v-for="item in blood_type"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="国籍:">
                  <el-select v-model="listUser.country" :disabled="listType == 1" style="width:100%;" filterable placeholder="请输入可搜索国家">
                    <el-option
                      v-for="item in country"
                      :key="item.value"
                      :label="item.name"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="病人性质:">
                  <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.nature" placeholder="请选择病人性质">
                    <el-option
                      v-for="item in nature"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item> 
              </el-col>
         
            </el-col> 
            <el-col :span="24">
                 <el-col :span="6">
                <el-form-item label="婚姻状况:">
                  <el-select style="width:100%" v-model="listUser.marriage" :disabled="listType == 1" placeholder="请选择婚姻状况">
                    <el-option
                      v-for="item in marriage"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              
              <el-col :span="6">
                <el-form-item label="民族:">
                  <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.nation" filterable placeholder="请选择民族">
                    <el-option
                      v-for="item in nation"
                      :key="item.value"
                      :label="item.name"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="媒介来源:">
                    <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.source" filterable placeholder="请选择媒介来源">
                    <el-option
                      v-for="item in source"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
                 <el-col :span="6">
                <el-form-item label="现住址:">
                      <el-input v-model="listUser.address" :disabled="listType == 1" placeholder="请输入年龄"></el-input>
                </el-form-item>
              </el-col>
            </el-col> 
            <el-col :span="24" style="font-size:24px;margin:0px 0 10px 0;">
              补充信息
            </el-col>
            <el-col :span="24">
              <el-col :span="6"> 
                <el-form-item label="籍贯:">
                  <el-input v-model="listUser.native_place" :disabled="listType == 1" placeholder="请输入籍贯"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="移动电话:">
                  <el-input v-model="listUser.phone" :disabled="listType == 1" placeholder="请输入移动电话"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="紧急联系电话:">
                  <el-input v-model="listUser.fast_phone" :disabled="listType == 1" placeholder="请输入紧急联系电话"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="户籍地址:">
                  <el-input v-model="listUser.home_address" :disabled="listType == 1" placeholder="请输入户籍地址"></el-input>
                </el-form-item>
              </el-col>
            </el-col>
            <el-col :span="24">
              <el-col :span="6"> 
                <el-form-item label="职业:">
                  <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.post" placeholder="请选择职业">
                    <el-option
                      v-for="item in post"
                      :key="item.value"
                      :label="item.name"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="工作单位:">
                   <el-input v-model="listUser.company" :disabled="listType == 1" placeholder="请输入工作单位"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="证件类型:">
                  <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.card_type" placeholder="请选择证件类型">
                    <el-option
                      v-for="item in card_type"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="证件号码:">
                   <el-input v-model="listUser.card_number" :disabled="listType == 1" placeholder="请输入证件号码"></el-input>
                </el-form-item>
              </el-col>
            </el-col>
            <el-col :span="24">
              <el-col :span="6"> 
                <el-form-item label="密级:">
                  <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.secret_level" placeholder="请选择密级">
                    <el-option
                      v-for="item in secret_level"
                      :key="item.value"
                      :label="item.name"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="学历:">
                  <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.edu_level" placeholder="请选择学历">
                    <el-option
                      v-for="item in edu_level"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="生育状态:">
                  <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.birth_status" placeholder="请选择生育状态">
                    <el-option
                      v-for="item in birth_status"
                      :key="item.value"
                      :label="item.name"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="保险类型:">
                  <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.insurance_no" placeholder="请选择保险类型">
                    <el-option
                      v-for="item in insurance_no"
                      :key="item.value"
                      :label="item.name"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-col>
            <el-col :span="24">
              <el-col :span="6"> 
                <el-form-item label="社会保障号:">
                  <el-input v-model="listUser.social_card" :disabled="listType == 1" placeholder="请输入社会保障号"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="是否异地:">
                  <el-select style="width:100%" :disabled="listType == 1" v-model="listUser.is_nolocal" placeholder="请选择是否异地">
                    <el-option
                      v-for="item in is_nolocal"
                      :key="item.value"
                      :label="item.name"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="备注:">
                  <el-input type="textarea" :disabled="listType == 1" v-model="listUser.extra_json" placeholder="请输入备注"></el-input>
                </el-form-item>
              </el-col>
            </el-col>
            <el-col :span="24">
              <el-form-item label="照片:">
                <el-upload
                  class="avatar-uploader"
                  :headers="headers"
                  :disabled="listType == 1"
                  :action="http + '/upload/image'"
                  :show-file-list="false"
                  :on-success="handleAvatarSuccess"
                  :before-upload="beforeAvatarUpload">
                  <img v-if="imageUrl" :src="imageUrl" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-col :span="24" v-for="(item,key) in listUser.family" :key="key">
                <el-col :span="24" style="font-size:24px;margin:0px 0 10px 0;"> 
                  家庭成员{{key+1}}
                </el-col>
                <el-col :span="24">
                    <el-col :span="7">
                      <el-form-item label="名字:">
                        <el-input v-model="item.name" :disabled="listType == 1" placeholder="请输入家庭成员名字"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="7">
                      <el-form-item label="手机号:">
                        <el-input v-model="item.phone" :disabled="listType == 1" placeholder="请输入家庭成员手机号"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="7">
                      <el-form-item label="家庭成员性别:">
                          <el-select style="width:100%" :disabled="listType == 1" v-model="item.gender" placeholder="请选择家庭成员性别">
                            <el-option
                              v-for="item in sex"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                            </el-option>
                          </el-select>
                      </el-form-item>
                    </el-col>
                </el-col>
                <el-col :span="24">
                    <el-col :span="7">
                      <el-form-item label="家庭成员生日:">
                      <el-date-picker
                          style="width:100%;"
                          :disabled="listType == 1"
                          v-model="item.birthday"
                          type="date"
                          placeholder="选择生日">
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                    <el-col :span="7">
                      <el-form-item label="家庭成员关系:">
                        <el-input v-model="item.relation" :disabled="listType == 1" placeholder="请输入家庭成员关系"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="7">
                      <el-form-item label="家庭成员地址:">
                        <el-input v-model="item.address" :disabled="listType == 1" placeholder="请输入家庭成员地址"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="2" :offset="1">
                        <el-button type="primary" :disabled="listType == 1" @click="handleDeleteFamily(key)">删除成员</el-button>
                    </el-col>
                </el-col>
              </el-col>
              <el-col :span="24">
                <el-col :span="6">
                  <el-form-item label="添加家庭成员:">
                    <el-button type="primary" :disabled="listType == 1" @click="handleAddFamily">添加成员</el-button>
                  </el-form-item>
                </el-col>
              </el-col>
            </el-col>
             <el-col :span="24">
              <el-col :span="24" v-for="(item,key) in listUser.with_user" :key="key">
                <el-col :span="24" style="font-size:24px;margin:0px 0 10px 0;"> 
                  陪护人{{key+1}}
                </el-col>
                <el-col :span="24">
                    <el-col :span="7">
                      <el-form-item label="名字:">
                        <el-input v-model="item.name" :disabled="listType == 1" placeholder="请输入家庭成员名字"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="7">
                      <el-form-item label="手机号:">
                        <el-input v-model="item.phone" :disabled="listType == 1" placeholder="请输入家庭成员手机号"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="7">
                      <el-form-item label="陪护人性别:">
                          <el-select style="width:100%" :disabled="listType == 1" v-model="item.gender" placeholder="请选择陪护人性别">
                            <el-option
                              v-for="item in sex"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                            </el-option>
                          </el-select>
                      </el-form-item>
                    </el-col>
                </el-col>
                <el-col :span="24" style="display:flex;">
                    <el-col :span="7">
                      <el-form-item label="家庭成员关系:">
                        <el-input v-model="item.relation" :disabled="listType == 1" placeholder="请输入家庭成员关系"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="7">
                      
                    </el-col>
                    <el-col :span="2" :offset="1" style="marginLeft:auto;">
                        <el-button type="primary" :disabled="listType == 1" @click="handleDeletePeople(key)">删除成员</el-button>
                    </el-col>
                </el-col>
              </el-col>
              <el-col :span="24">
                <el-col :span="6">
                  <el-form-item label="陪护人信息:">
                    <el-button type="primary" :disabled="listType == 1" @click="handleAddPeople">添加陪护人</el-button>
                  </el-form-item>
                </el-col>
              </el-col>
            </el-col>
          </el-form>
        </el-col>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="listFlag = false">取 消</el-button>
        <el-button type="primary" @click="addSave()">确 定</el-button>
      </span>
    </el-dialog>
  </el-row>
  </div>
</template>

<script>
import {getMemberIndex,addSave,getProfileInfo,getSetStatus} from "@/api/patient"
import TopManu from "@/components/TopMenu";
import {Format} from "@/utils/transtionDate"
import FromList from "@/forComponents/fromList/fromList"
import {patientTitle} from "./tableTitle.js"
import {handleDictIndex} from "@/api/organization"
import {http} from "@/utils/server"
import {objectValueAllEmpty} from "@/utils/ifObject"
// import {} from ""
let that
export default {
  name:"patient",
  data(){
    return {
        topmanuArry:[{
        class:'icon-his_60_pandian',
        name:'慢特病',
        key:'1',
      }],
      top:"0",
      userCount:0,
      Inquire:{  //搜索数据
        keyword:"",
        status:"",
        created_at:[],
      },
      pickerOptions: {   //时间快捷选项
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      tableData:[],
      tableTitle:patientTitle,
      listFlag:false, //弹窗开关
      listType:2, //1查看,2添加,3编辑
      listUser:{
        name:"", //姓名
        id_card:"", //身份证号
        gender:"", //性别
        age:"", //年龄
        phone:"", //手机号
        birthday:"", //生日
        marriage:"", //婚姻状态   1未知 2未婚 3已婚 4离异 5丧偶
        blood_type:"", //血型  @1 A型 @2 B型 @3 O型 @4 AB型 @5 未知
        rh_blood_type:"", //rh血型 @1阴性 @2 阳性  @3 未知	
        country:"CHN", //国家， 字典id 33，这里需要的是字典的name值
        nation:"", //民族 字典id 37，这里需要的是字典的name值
        address	:"", // 住址
        social_card:"", //社保卡号
        source:"", //媒介来源 40
        nature:"", //病人性质: 读取数据字典   4 取字典的id 值
        post:"", //职业
        company:"", //所在单位
        email:"", //邮箱
        native_place:"", //籍贯
        zip_code:"", //邮编
        tel:"", //家庭电话
        card_type:"",// 证件类型  : 读取数据字典   25 取字典的id 值
        card_number:"", //证件号码
        secret_level:"", //密级 @1 普通 @2 机密@3 绝密
        home_address:"", //户籍地址
        edu_level:"", //学历  数据字典为 39，取值为name	
        birth_status:"", //生育状态 @1 未育 @2 已育
        is_nolocal:"", //是否外地  @1 是  @2 否
        avatar:"", //照片地址
        fast_name:"", //紧急联系人
        fast_phone:"", //联系人手机号
        insurance_no:"", //保险类型
        family:[
         {
           name:"", //家庭成员姓名
           phone:"", //家庭成员手机号
           gender:"", //家庭成员性别
           birthday:"", //家庭成员生日
           relation:"", //家庭成员关系
           address:"", //家庭成员地址
         }
        ],
        with_user:[
           {
             name:"",
             phone:"",
             gender:"",
             relation:""
           }
        ]
      },
      sex:[
        {
          value:1,
          label: '男'
        }, {
          value:2,
          label: '女'
        }
      ],
      marriage:[
        {
          value:1,
          label: '未知'
        },
        {
          value:2,
          label: '未婚'
        },
         {
          value:3,
          label: '已婚'
        },
         {
          value:4,
          label: '离异'
        },
         {
          value:5,
          label: '丧偶'
        }
      ],
      blood_type:[  //血型select
        {
          value:1,
          label: 'A型'
        },
        {
          value:2,
          label: 'B型'
        },
         {
          value:3,
          label: 'O型'
        },
         {
          value: '4',
          label: 'AB型'
        },
         {
          value: '5',
          label: '未知'
        }
      ],
      rh_blood_type:[ //RH血型select
        {
          value:1,
          label: '阴性'
        },
        {
          value:2,
          label: '阳性'
        },
         {
          value:3,
          label: '未知'
        }
      ],
      birth_status:[  //生育状态
        {
          value:1,
          label: '未育'
        },
        {
          value:2,
          label: '已育'
        }
      ],
      is_nolocal:[ //是否外地select
        {
          value:1,
          label: '是'
        },
        {
          value:2,
          label: '否'
        }
      ],
      country:[

      ],
      nature:[

      ],
      post:[

      ],
      card_type:[

      ],
      secret_level:[
        {
          value:1,
          name:"普通"
        },
        {
          value:2,
          name:"机密"
        },
         {
          value:3,
          name:"绝密"
        }
      ],
      edu_level:[

      ],  
      birth_status:[
        {
          value:1,
          name:"未育"
        },
        {
          value:2,
          name:"已育"
        }
      ],
      is_nolocal:[
        {
          value:1,
          name:"是"
        },
        {
          value:2,
          name:"否"
        }
      ],
      insurance_no:[

      ],
      nation:[

      ],
      source:[
        
      ],
      http:http,
      headers:{
        Authorization:"Bearer " + localStorage.getItem("token")
      },
      imageUrl:"",
      page:1,
      limit:8

    }
  },
  mounted(){
    that = this
    that.getMemberIndex()
    that.getAll()
  },
  methods:{
        getInfo2(idCard) {
        let sex = null;
        let birth = null;
        let myDate = new Date();
        let month = myDate.getMonth() + 1;
        let day = myDate.getDate();
        let age = 0;

        if (idCard.length === 18) {
          age = myDate.getFullYear() - idCard.substring(6, 10) - 1;
          sex = idCard.substring(16, 17);
          birth = idCard.substring(6, 10) + "-" + idCard.substring(10, 12) + "-" + idCard.substring(12, 14);
          if (idCard.substring(10, 12) < month || idCard.substring(10, 12) === month && idCard.substring(12, 14) <= day)
            age++;

        }
        if (idCard.length === 15) {
          age = myDate.getFullYear() - idCard.substring(6, 8) - 1901;
          sex = idCard.substring(13, 14);
          birth = "19" + idCard.substring(6, 8) + "-" + idCard.substring(8, 10) + "-" + idCard.substring(10, 12);
          if (idCard.substring(8, 10) < month || idCard.substring(8, 10) === month && idCard.substring(10, 12) <= day)
            age++;
        }

        if (sex % 2 === 0)
          sex = 0; // 性别代码 1代表男，0代表女，暂时不涉及其他类型性别
        else
          sex = 1;
           this.listUser.gender=sex
         this.listUser.birthday=birth
       this.listUser.age=age
  
      },
    handlePagination(e){
      this.tabData = []
      this.page = e
      this.getMemberIndex()
    },
    handcreate(item){
      console.log("123")
      this.$router.push({name:'chronicIdiopathicDisease'})
    },
   getProfileInfo(e){
     getProfileInfo({id_card:e})
     .then(res=>{
       res.data.family = res.data.get_family
       that.getAll()
       res.data.edu_level = parseFloat(res.data.edu_level)      
       that.listUser = res.data
     })
     .catch(e=>{
       that.$message({
        message:e.message,
        type: 'error'
      });
     })
   },
   // 操作按钮
   handleEdit(e){
     console.log(e)
     if(e.key == 1){
       that.getProfileInfo(e.data.id_card)
       that.listFlag = true
       that.listType = 1
     }else if(e.key == 2){
       that.getProfileInfo(e.data.id_card)
       that.listFlag = true
       that.listType = 3
     }
   },
   // 状态操作
   handleSwitchChange(data){
     let {data:list} = data
     that.getSetStatus(list.id,list.flag ? 1 : 2)
   },
    //修改账户状态
    getSetStatus(e,q){
      getSetStatus({id:e,status:q})
      .then(res=>{
        this.$message({
          message:"修改状态成功",
          type: 'success'
        });
        that.tableData = []
        that.getMemberIndex()
      })
      .catch(e=>{
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    },
  //  删除家庭成员
   handleDeleteFamily(key){
     that.listUser.family.splice(key,1)
   },
    //  删除陪护人成员
   handleDeletePeople(key){
     that.listUser.with_user.splice(key,1)
   },
   handleAddFamily(){
    that.listUser.family.push(
      {
        name:"", //家庭成员姓名
        phone:"", //家庭成员手机号
        gender:"", //家庭成员性别
        birthday:"", //家庭成员生日
        relation:"", //家庭成员关系
        address:"", //家庭成员地址
      }
    )
   },
    handleAddPeople(){
      that.listUser.with_user.push(
        {
          name:"",
          phone:"",
          gender:"",
          relation:""
        }
      )
   },
   addSave(){
    let data = {
      name:"",
      id_card:"",
      gender:""
    }
    let list = {

    }
    Object.keys(data).forEach(key=>{
      data[key] = that.listUser[key]
    })
    Object.keys(that.listUser).forEach((item,key)=>{
      if(item != "get_family"){
        list[item] = that.listUser[item]
      }
    })
    that.listUser = list
    if(!objectValueAllEmpty(data)){
      this.$message({
          message:"请认真填写表单信息",
          type: 'error'
        });
      return false
    }
    addSave({...that.listUser})
    .then(res=>{
      that.$message({
        message:res.message,
        type: 'success'
      });
      that.listUser = that.$options.data.call(this).listUser
      that.listFlag = false
      that.getMemberIndex()
    })
    .catch(e=>{
      that.$message({
        message:e.message,
        type: 'error'
      });
    })
   },
  //  关闭弹窗
   handleClose(){
    that.listFlag = false
   },
  //  获取数据字典
   getAll(){
    that.handleDictIndex("33,4,22,25,39,13,37,40")
   },
  //  获取数据字典
   handleDictIndex(e){
     handleDictIndex({group_id:e})
     .then(res=>{
       console.log(res)
       if(res.data.length != 0){
         res.data.forEach(item=>{
           switch(item.id){
             case 4:
              that.nature = item.items
             break
             case 33:
              that.country = item.items
             break
             case 22:
              that.post = item.items
             break
             case 25:
              that.card_type = item.items
             break
             case 39:
              that.edu_level = item.items
             break
             case 13:
              that.insurance_no = item.items
             break
             case 37:
              that.nation = item.items
             break
             case 40:
              that.source = item.items
             break
           }
         })
       }
     })
     .catch(e=>{
      this.$message({
        message:e.message,
        type: 'error'
      });
     })
   },
   handleAvatarSuccess(res,file){
      that.imageUrl = URL.createObjectURL(file.raw);
      that.listUser.avatar = res.data.url
   },
   //限制图片
   beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
        return isJPG && isLt2M;
   },
   getMemberIndex(){
    let data = JSON.parse(JSON.stringify(this.Inquire))
    if(data.created_at.length != 0){
      data.created_at = Format(new Date(data.created_at[0])) + "|"+ Format(new Date(data.created_at[1]))
    }

    getMemberIndex({...data,page:this.page,limit:this.limit})
    .then(res=>{
      if(res.data.list.length != 0){
        res.data.list.forEach((item,key)=>{
          item.key = key + 1
          item.genderName = item.gender == 1 ? '男' : '女' 
          item.status == 1 ? item.flag = true : item.flag = false
        })
      }
      this.userCount = res.data.count
      that.tableData = res.data.list
    })
    .catch(e=>{
      this.$message({
        message:e.message,
        type: 'error'
      });
    })
   }
  },
  components:{
    TopManu,
     FromList,
  },
}
</script>

<style lang='scss' scoped>
@import "./index.scss";
.el-dialog{
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
    border: 1px dashed #d9d9d9;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>